#!/usr/bin/env python
# -*- coding:utf-8 -*-

import sys
import os
import logging
logger = logging.getLogger(__name__)

from gen_py.HelloService import HelloService
from gen_py.HelloService.ttypes import *

from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer,  TProcessPoolServer

import json
json_loads = json.loads
json_dumps = json.dumps

import types



from multiprocessing import Process, Queue, Pool, Value, Condition, freeze_support


class HelloServiceHandler:
    def say_hello(self, jsonCondition):
        return "asdfasdfsdf" + jsonCondition

if __name__ == '__main__':
    
    handler = HelloServiceHandler()
    
    
    processor = HelloService.Processor(handler)
    transport = TSocket.TServerSocket('192.168.1.10',30303)
    tfactory = TTransport.TBufferedTransportFactory()
    pfactory = TBinaryProtocol.TBinaryProtocolFactory()
    
    #server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
    server = TProcessPoolServer.TProcessPoolServer(processor, transport, tfactory, pfactory)
    
    print ("Starting python server...")
    #freeze_support()
    server.serve()
    print( "done!")
